package com.javasm.finance.service.impl;

import com.javasm.finance.dao.CheckDao;
import com.javasm.finance.dao.impl.CheckDaoImpl;
import com.javasm.finance.entity.Prod;
import com.javasm.finance.service.CheckService;

import java.sql.SQLException;
import java.util.List;

public class CheckServiceImpl implements CheckService {
    CheckDao checkDao=new CheckDaoImpl();

    @Override
    public List<Prod> queryProd(Integer page, Integer pageSize, String prodName, String managerName, Integer prodState) {
        List<Prod> prodList= null;
        try {
            prodList =checkDao.queryProd(page,pageSize,prodName,managerName,prodState);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return prodList;
    }

    @Override
    public long findTotalNum(String prodName, String managerName, Integer prodState) {
        long totalNum = 0;
        try {
            totalNum = checkDao.findTotalNum(prodName,managerName,prodState);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return totalNum;
    }

    @Override
    public int deleteProd(Integer prodId){
        int rows = 0;
        try {
            rows = checkDao.deleteProd(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public Prod findByPid(Integer prodId) {
        Prod prod = null;
        try {
            prod = checkDao.findByPid(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return prod;
    }

    @Override
    public int edit(Integer prodId) {
        int rows = 0;
        try {
            rows = checkDao.edit(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }

    @Override
    public int failed(Integer prodId) {
        int rows = 0;
        try {
            rows = checkDao.failed(prodId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return rows;
    }
}
